package com.example.demo.controller;

import com.example.demo.mapper.HrmsHolidayDictionaryMapper;
import com.example.demo.pojo.HrmsHolidayDictionary;
import com.example.demo.service.HrmsHolidayDictionaryService;
import com.example.demo.utils.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.util.StopWatch;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author wangyunfei-jwk
 * @date 2024-02-04 17:28
 * @desciption:
 */
@Slf4j
@RestController
@RequestMapping("/admin")
public class HrmsHolidayDictionaryController {
    @Resource
    private HrmsHolidayDictionaryService dictionaryService;
    @Resource
    private RedisTemplate<String, String> redisTemplate;
    @GetMapping("/getAll")
    public Result getAll(){
        List<HrmsHolidayDictionary> list = dictionaryService.getAll();
        return Result.ok(list);
    }

    @GetMapping("/getById")
    public Result getById(@RequestParam("id") String id){
        HrmsHolidayDictionary hrmsHolidayDictionary = null;
        try {
            hrmsHolidayDictionary = dictionaryService.getByHrmsId(id);
        } catch (Exception e) {
            return Result.fail(e.getMessage());
        }
        return Result.ok(hrmsHolidayDictionary);
    }
}
